#include <stdio.h>
int main() 
{
    int h, f, x, y;

    printf("请输入头和脚的数量");
    scanf("%d %d", &h, &f);

    if (h <= 0 || f <= 0) {
        printf("无解\n");
    }
    else if (f % 2 != 0 || f < 2 * h || f > 4 * h)
    {
        printf("无解\n");
    }
    else 
    {
        y = (f - 2 * h) / 2;
        x = h - y;
        printf("鸡有%d只，兔有%d只\n", x, y);
    }

    return 0;
}
